import { Controller, Get, Post, Delete, Put, Body } from '@nestjs/common';
import { AppService } from './app.service';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { CreatePostDto } from './dto/create-post.dto';

@ApiTags('helloworld')
@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @ApiOperation({ summary: '说明:这个接口用来测试helloworld' })
  @Get('hello')
  getHello(): string {
    return this.appService.getHello();
  }

  @ApiOperation({ summary: '获取文章列表' })
  @Get('list')
  getRandom() {
    return this.appService.getList();
  }

  @ApiOperation({ summary: '新增文章' })
  @Post('')
  async postNew(@Body() post: CreatePostDto) {
    return 'ok';
  }

  @ApiOperation({ summary: '更新文章' })
  @Put('')
  updateOne() {
    return 'ok';
  }

  @ApiOperation({ summary: '删除文章' })
  @Delete('')
  deleteOne() {
    return 'ok';
  }
}
